package WinterHomework.day02;

//编写求1-10000之间所有“完全数”，完全数意思是，6的因数是3,2,1.6=3+2+1
public class Demo01 {
    public static void main(String[] args) {
        int count = 1;
        for (int i = 1; i <= 10000; i++) {
            if (perfectNumber(i)) {
                if (count % 10 == 0) {
                    System.out.println(i);
                    count = 0;
                } else {
                    System.out.print(i + ",");
                    count++;
                }
            }
        }
    }

    public static boolean perfectNumber(int num) {
        int sum = 0;
        for (int i = 1; i <= num / 2; i++) {
            if (num % i == 0) {
                sum += i;
            }
        }
        return sum == num;
    }
}
